#pragma once

#include "AbstractLock.h"

class Lock_RFV42 : public AbstractLock
{
public:
	struct ReadResult
	{
		QDateTime EndTime();

		QString LockId;
		QString CardId;
		QDateTime StartTime;		
		int TimeUnit;
		int TimeLen;
		int CheckOutHour;
		int OpenInner;
	};

	Lock_RFV42();
	~Lock_RFV42();
	
	bool isVaild();

	int OpenPort(int index);
	int ClosePort();
	int WriteCard(QString lockNo,QString datetime,int xh,int sjdw,int sjlength,int gs,int nLockAp,int nCheckOutHour,int nOpenInner);
	int ReadCard(int nLockAp,ReadResult &ret);

	QString errorMessage(int r);
	Json::Value DealCommand(QString cmd,Json::Value &param);

protected:	
	bool checkParam(QString cmd,Json::Value &param,QString &error);	
	void initDevice();
	bool m_init;

	int m_com;
	int m_sysAp;
};